<template>
	<barLayout navTitle="数字酷" :showHomeIcon="false">
		<view class="activity flex-main">
			<view class="main">
				<view class="mainContent">
					<text class="title">体测任务</text>
					<view v-if="list.length">
						<view class="card" v-for="(item, index) in list" :key="index">
							<image :src="item.photoPath || 'https://edu.c-eplus.com/activityfiles/miniapp/static/image/defaultBg.png'" class="img"></image>
							<view class="card-content">
								<view class="content-top">
									<text>{{ item.name }}</text>
									<view class="time-content">
										<image src="https://edu.c-eplus.com/activityfiles/miniapp/static/image/timer.png" class="timer"></image>
										<text>{{ item.startTime }}</text>
									</view>
								</view>
								<view class="content-btom">
									<view class="btom-item" @click="toSignUp(item.name, item.dcActivityId)">
										<view class="item"><image src="https://edu.c-eplus.com/activityfiles/miniapp/static/image/edit.png" class="icons" mode="aspectFit"></image></view>
										<text class="label">我要报名</text>
									</view>
									<view class="btom-item" @click="toReport(item.dcActivityId)">
										<view class="item item2"><image src="https://edu.c-eplus.com/activityfiles/miniapp/static/image/book.png" class="icons" mode="aspectFit"></image></view>
										<text class="label">成绩报告</text>
									</view>
								</view>
							</view>
						</view>
					</view>
					<view v-else class="noData">
						<image src="https://edu.c-eplus.com/activityfiles/miniapp/static/image/noData.png" class="noDataImg"></image>
						<text class="nodataText">暂无活动</text>
					</view>
				</view>
			</view>
		</view>
	</barLayout>
</template>

<script>
import barLayout from '@/pages/layout/barLayout.vue';
import { getActivityList } from '@/api/activity.js';
import routerPermission from '@/api/request/routerPermission.js';
export default {
	components: {
		barLayout
	},
	data() {
		return {
			list: [{
				name:'2023年国标体测'
			}]
		};
	},
	onLoad() {
		routerPermission();
		this.getData();
	},
	onPullDownRefresh() {
		this.list = [];
		setTimeout(() => {
			this.getData();
		}, 1000);
	},
	methods: {
		getData() {
			getActivityList().then(res => {
				let { data, success, errMsg } = res.data;
				if (success) {
					if (data && data.length) {
						this.list = data || [];
					}
				} else {
					uni.showModal({
						content: errMsg,
						showCancel: false
					});
				}
				uni.stopPullDownRefresh();
			});
		},
		toSignUp(title, dcActivityId) {
			uni.navigateTo({
				url: '/pages/activity/signUp?title=' + title + '&dcActivityId=' + dcActivityId
			});
		},
		toReport(dcActivityId) {
			uni.navigateTo({
				url: '/pages/activity/scoreList?dcActivityId=' + dcActivityId
			});
		}
	}
};
</script>

<style></style>
